package cn.edu.gdpt.mobile213.mobile2121606097wjc0328;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private EditText edttxtmainNuma;
    private EditText edttxtmainNumb;
    private Button btnmainResult;
    private TextView tvmainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initview();
        btnmainResult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String numa= edttxtmainNuma.getText().toString();
                String numb= edttxtmainNumb.getText().toString();
                int a= Integer.valueOf(numa);
                int b= Integer.valueOf(numb);

                int result=a+b;
                tvmainResult.setText(String.valueOf(result));
            }
        });
    }

    private void initview() {
        edttxtmainNuma=(EditText) findViewById(R.id.edttxtmainNuma);
        edttxtmainNumb=(EditText) findViewById(R.id.edttxtmainNumb);
        btnmainResult=(Button) findViewById(R.id.btnmainResult);
        tvmainResult=(TextView) findViewById(R.id.tvmainResult);
    }
}